# Create your models here.

from django.db import models

# Create your models here.
from mlh.utils.models import BaseModel


class Question(BaseModel):
    user = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name="questionset", verbose_name="提问人")
    title = models.CharField(max_length=64, verbose_name="问题标题")
    desc = models.TextField(max_length=None, verbose_name="问题描述")
    browsing_volume = models.IntegerField(max_length=None, verbose_name="浏览量")
    label = models.ForeignKey('Label', on_delete=models.CASCADE, verbose_name="所属问题")

    class Meta:
        db_table = 'tb_question'
        verbose_name = "问题表"
        verbose_name_plural = verbose_name


class Anwser(BaseModel):
    user = models.ForeignKey('users.User', on_delete=models.CASCADE, related_name="anwserset", verbose_name="评论人")
    desc = models.TextField(max_length=None, verbose_name="评论内容")
    question = models.ForeignKey('Question', on_delete=models.CASCADE, related_name="anwserset", verbose_name="对应问题")
    is_delete = models.BooleanField(default=False, verbose_name="逻辑删除")
    like = models.BooleanField(default=False, verbose_name="点赞")

    class Meta:
        db_table = 'tb_answer'
        verbose_name = "回答表"
        verbose_name_plural = verbose_name


class Label(BaseModel):
    name = models.CharField(max_length=64, verbose_name="标签名字")
    follow = models.BooleanField(default=False, verbose_name="关注状态")
    follow_count= models.IntegerField(verbose_name="关注数量")
    desc = models.TextField(verbose_name="标签描述")

    class Meta:
        db_table = 'tb_label'
        verbose_name = "标签表"
        verbose_name_plural = verbose_name
